<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="java.io.*"%>
<%@page import="java.util.regex.Pattern"%>
<%@page import="java.util.regex.Matcher"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	String filePath = basePath + "json";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP 'MyJsp.jsp' starting page</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
		<script type="text/javascript" src="<%=basePath%>ofc2/swfobject.js"></script>
	</head>
	<script type="text/javascript">
  	function makeFlash(id,heigth,width,url){
		swfobject.embedSWF(
			"<%=basePath%>ofc2/open-flash-chart.swf", 
			id, 
			heigth, 
			width, 
			"9.0.0",
			"expressInstall.swf",
			{"data-file":url},
			{wmode:"transparent"}
		);
	}
	
  	function test(name){
  		var dataName = name+'.json';
  		makeFlash("bar-filled","600","400","<%=basePath%>/json/"+dataName)
  	}
  </script>
	<body>
	<table border=1 color ="#000000">
	<tr>
	<%
	
	//out.println(filePath);
	File dir = new File(request.getRealPath("")+"/json");
	int i = 0;
	for(File file : dir.listFiles()){
		++i;
		String fName = file.getName();
		String lastName = fName.substring(0,fName.lastIndexOf("."));
		if(i%5 == 0){
			%>
			</tr><tr>
			<%
		}
		%>
		<td ><a onclick="test('<%=lastName %>')"><%=lastName %></a></td>
		<%
	}
	%>
	</tr>
	<tr><td colspan=5><div id="bar-filled"></div></td></tr>
	</table>
		
	</body>
</html>
